package dyyx.cli;

import dyyx.util.CommUtil;
import dyyx.util.HostInfoUtil;
import dyyx.util.ProcUtil;

public class DevToolMain {
	
	private static final String VERSION = "devtool-2019-05-06 18:50";

	public static void main(final String[] args) {
		// System.out.println("devtool,"+new Date());
		
		String type = null;
		if(args!=null && args.length>0){
			type = args[0];
		}else{
			System.out.println("please input type,version or ip or metrics or process-status");
			return;
		}
		
		if("version".equals(type)){
			System.out.println(VERSION);
			return;
		}
		
		if("ip".equals(type)){
			System.out.println(HostInfoUtil.getHostIp());
			return;
		}
		
		if("metrics".equals(type)){
			System.out.println(ProcUtil.buildMetricData());
			return;
		}
		
		if("process-status".equals(type)){
			long pid = 0;
			if(args.length > 1){
				pid = CommUtil.getLong(args[1]);
			}
			if(pid<=0){
				System.out.println("pid error,process-status PID");
				return;
			}
			System.out.println(ProcUtil.getProcessStatusMap(pid));
			return;
		}
		
		
		System.out.println("type error");

		
		
		
		
	}

}